home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 297_01 / exampl10.spr < prev    next >
Text File  |  1980-01-01  |  752b  |  34 lines

  1. /* example10.spr */
  2. /* using findall */
  3. /* findall is a special predicate that lets you build
  4.    lists much in the way sets are often defined.
  5.    It is defined in sprolog.ini
  6.  
  7.   A call to a goal fo the form 
  8.  
  9.    (findall X Goal L)
  10.  
  11. will match L with the list of all X such the Goal is true.
  12.  
  13. try (findall Person (lives_in Person europe) Europeans)
  14. */
  15.  
  16. (lives_in_state henri france)
  17. (lives_in_state edmund france)
  18. (lives_in_state anca new_york)
  19. (lives_in_state brian florida)
  20.  
  21. ((lives_in X Federation)
  22.  (lives_in_state X State)
  23.  (state_of State Federation)
  24. )
  25.  
  26. (state_of france europe)
  27. (state_of florida usa)
  28. (state_of new_york usa)
  29.  
  30. ((demo10)
  31.  (findall Person (lives_in Person europe) Europeans)
  32.  (display Europeans)
  33. )
  34.